package notesDetection.Utilities;

public class Harmonic
{
	private double _amplitude;
	private double _phase;
	private double _frequency;	//	 radians (or angles) per sample
	
	public Harmonic(int cycleLength, double real, double imag)
	{
		_amplitude = Math.sqrt(real * real + imag * imag);	//	We might have to normalize the values according to segment length
		_phase = Math.atan2(imag, real);
		_frequency = (360.0 / cycleLength) * (Math.PI / 180);	//	Radians per sample
	}
	
	public double getValueAt(int sampleIndex)
	{
		return _amplitude * Math.cos(sampleIndex * _frequency + _phase);
	}
	
}
